/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bgu.ppm.gtm.agents;

import bgu.ppm.gtm.base.GameTheoryModel;
import bgu.ppm.gtm.base.ImmutableStrategy;
import bgu.ppm.gtm.base.Strategies;
import bgu.ppm.gtm.base.StrategyProfile;
import bgu.ppm.sim.impl.mas.agents.AbstractAgent;

/**
 *
 * @author User
 */
public abstract class TurnBasedAgent<T extends GameTheoryModel> extends AbstractAgent<T> {

    @Override
    protected final void _tick() {
        doTurn(getModel().getCurrentStrategyProfile());
    }

    @Override
    protected final void _initialize(T model) {
        start();
    }

    protected void submitCurrentStrategy(ImmutableStrategy strategy) {
        getModel().selectStrategy(getId(), strategy);
    }

    protected Strategies getStrategies() {
        return getModel().getStrategiesFor(getId());
    }

    protected ImmutableStrategy findBestResponse(StrategyProfile profile) {
        return getModel().getBestResponseFinder().findBestResponse(getId(), profile);
    }

    protected double utility(ImmutableStrategy s_i, StrategyProfile others) {
        return getModel().getUtilityFunction().calculate(getId(), s_i, others);
    }

    protected double cost(ImmutableStrategy s_i, StrategyProfile others) {
        return getModel().getCostFunction().calculate(getId(), s_i, others);
    }

    protected abstract void doTurn(StrategyProfile currentStrategyProfile);
}
